from collections import defaultdict


def f(s):
    dic=defaultdict(int)
    ans=0
    i=0
    j=1
    dic[s[i]]+=1
    while j<len(s):
        while j<len(s) and dic[s[j]]<1:
            dic[s[j]]+=1
            j+=1
        ans=max(ans,j-i)
        while i<j and dic[s[i]]>1:
            dic[s[i]]-=1
            i+=1
        # 考试的时候忘记加这两行了
        i+=1
        j+=1
    return ans
s='acaacv'
print(f(s))